% Beamer style for posters inspired from: https://github.com/UCL-INMA/ICTEAMposter
\ProvidesPackage{styles/beamerthemeICTEAMposter}
\RequirePackage{tikz}		% for drawing the nice rounded boxes
\RequirePackage{fontspec}
\RequirePackage{textcomp}
\RequirePackage{amsmath,amssymb}

\usetikzlibrary{arrows,backgrounds}

\setmainfont[Path=./fonts/]{Montserrat}[
Extension = .ttf,
UprightFont=*-Regular,
BoldFont=*-Bold,
ItalicFont=*-Italic,
BoldItalicFont=*-BoldItalic]

%\usefonttheme{professionalfonts}
\newcommand{\makeruleinbox}{{\usebeamercolor[bg]{block alerted title}\centering\hspace*{-0.7cm}\rule{\inboxrule}{0.5cm}}}
\usepackage{ragged2e}

% Spacing before and inside list environments to add white space before lists and between items inside lists
\makeatletter
\def\@listi{\leftmargin\leftmarginii
\topsep 1ex % Spacing before lists
\parsep 0\p@ \@plus\p@
\itemsep 6pt} % Spacing between items
\makeatother

\usecaptiontemplate{\small\structure{\insertcaptionname~\insertcaptionnumber: }\insertcaption} % A fix for figure numbering

% set the basic colors
\setbeamercolor{palette primary}   {fg=black,bg=white}
\setbeamercolor{palette secondary} {fg=black,bg=white}
\setbeamercolor{palette tertiary}  {bg=UCLouvainBleuNuit,fg=white}
\setbeamercolor{palette quaternary}{fg=black,bg=white}
\setbeamercolor{structure}{fg=UCLouvainBleuNuit}
\setbeamercolor{titlelike}         {bg=UCLouvainBleuNuit,fg=white}
\setbeamercolor{frametitle}        {bg=UCLouvainBleuNuit!10,fg=UCLouvainBleuNuit}
\setbeamercolor{cboxb}{fg=black,bg=UCLouvainBleuNuit}
\setbeamercolor{cboxr}{fg=black,bg=red}

% set colors for itemize/enumerate
\setbeamercolor{item}{fg=UCLouvainBleuGris}
\setbeamercolor{item projected}{fg=white,bg=UCLouvainBleuGris}

% set colors for blocks
\setbeamercolor{block title}{fg=ICTEAM, bg=white}
\setbeamercolor{block body}{fg=black,bg=white}

% set colors for alerted blocks (blocks with frame)
\setbeamercolor{block alerted title}{fg=white,bg=UCLouvainBleuNuit}
\setbeamercolor{block alerted body}{fg=black,bg=UCLouvainBleuNuit!10}
\setbeamerfont{alerted text}{series=\bfseries}
\setbeamercolor{alerted text}{fg=UCLouvainCyan}

% set the fonts
\setbeamerfont{section in head/foot}{series=\bfseries}
\setbeamerfont{block title}{series=\bfseries}
\setbeamerfont{block alerted title}{series=\bfseries}
\setbeamerfont{frametitle}{series=\bfseries}
\setbeamerfont{frametitle}{size=\Large}
\setbeamerfont{block body}{series=\rmfamily}

% set some beamer theme options
\setbeamertemplate{title page}[default][colsep=-4bp,rounded=true]
\setbeamertemplate{sections/subsections in toc}[square]
\setbeamertemplate{items}[circle]
\setbeamertemplate{blocks}[width=0.0]
\beamertemplatenavigationsymbolsempty

% set bibliography style
\setbeamertemplate{bibliography item}[text]
\setbeamercolor{bibliography item}{fg=black,bg=white}
\setbeamercolor{bibliography entry author}{fg=black,bg=white}
\setbeamercolor{bibliography item}{fg=black,bg=white}

% define some length variables that are used by the template
\newlength{\inboxwd}
\newlength{\iinboxwd}
\newlength{\inboxrule}
\makeatletter
\makeatother

%==============================================================================
% build the poster title
%==============================================================================
\setbeamertemplate{headline}{
 \leavevmode
  \begin{columns}
   \begin{column}{0.3\linewidth}
     \includegraphics[height=10cm]{imgs/logo1.png}
   \end{column}
   \begin{column}{0.48\linewidth}
   \end{column}
   \begin{column}{0.3\linewidth}
     \includegraphics[height=8cm]{imgs/logo2.png}
   \end{column}
  \end{columns}
  \vspace{-2cm}
  \begin{columns}
   \begin{column}{0.02\linewidth}
     % For centering the title horizontally
   \end{column}
   \begin{column}{0.96\linewidth}
    \vskip1cm
    \centering
    \usebeamercolor{title in headline}{\color{UCLouvainBleuNuit}\Huge{\textbf{\inserttitle}}\\[0.5ex]}
    \usebeamercolor{author in headline}{\color{fg}\Large{\insertauthor}\\[1ex]}
    \usebeamercolor{institute in headline}{\color{fg}\large{\insertinstitute}\\[1ex]}
    \vskip1cm
   \end{column}
   \begin{column}{0.02\linewidth}
     \vspace{4cm}\\
     \includegraphics[height=6cm]{imgs/I.png}
   \end{column}
  \end{columns}
 \vspace{0.5in}
 \hspace{0.5in}\begin{beamercolorbox}[wd=35in,colsep=0.15cm]{cboxb}\end{beamercolorbox}
 \vspace{0.1in}
}

\setbeamertemplate{footline}{
 \leavevmode
  \begin{columns}
   \begin{column}{0.08\linewidth}
     \hspace{2cm}\includegraphics[height=6cm]{imgs/L.png}
   \end{column}
   \begin{column}{0.42\linewidth}
     \begin{block}{References}
       \printbibliography
     \end{block}
   \end{column}
   \begin{column}{0.6\linewidth}
   \end{column}
  \end{columns}
 \vspace{0.5in}
 \hspace{0.5in}\begin{beamercolorbox}[wd=35in,colsep=0.15cm]{cboxb}\end{beamercolorbox}
 \vspace{0.1in}
}


% Block definition
\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[colsep*=0ex,dp={2ex},center]{block title}
    \vskip-0.25cm
    \usebeamerfont{block title}\large\insertblocktitle
    \begin{flushleft}
    \vskip-1cm
    \begin{tikzpicture}[remember picture,overlay]
      \shade [inner color=UCLouvainBleuGris, outer color=white]
      (0,0) rectangle (\textwidth,0.3cm);
    \end{tikzpicture}
    \end{flushleft}
  \end{beamercolorbox}
  {\parskip0pt\par}
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}
  \usebeamerfont{block body}
  \vskip-0.5cm
  \begin{beamercolorbox}[colsep*=0ex,vmode]{block body}
  \justifying
}

\setbeamertemplate{block end}
{
  \end{beamercolorbox}
  \vskip\smallskipamount
}

% Alert block definition (with frame)
\setbeamertemplate{block alerted begin}
{
  \par\vskip\medskipamount
  \begin{beamercolorbox}[sep=0ex,rounded=true,center,dp={2ex}]{block alerted title}
    \vskip0.01cm
    \usebeamerfont{block title}\large\insertblocktitle
  \end{beamercolorbox}
  {\parskip0pt\par}
  \usebeamerfont{block body}
  \vskip-0.8cm
  \begin{beamercolorbox}[sep=0.5cm, rounded=true,center]{block alerted title}
  \setlength{\inboxwd}{\linewidth}
  \addtolength{\inboxwd}{-1cm}
  \begin{beamercolorbox}[rounded=true,wd={\inboxwd},center]{block alerted body}
  \setlength{\iinboxwd}{\inboxwd}
  \setlength{\inboxrule}{\inboxwd}
  \addtolength{\iinboxwd}{-0.5cm}
  \addtolength{\inboxrule}{0.5cm}
  \begin{center}
  \begin{minipage}{\iinboxwd}
  \justifying
}

\setbeamertemplate{block alerted end}
{
  \end{minipage}
  \end{center}
  \end{beamercolorbox}
  \end{beamercolorbox}
  \vskip\smallskipamount
}
